package top.wshape1.shiziapi.project.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.wshape1.shiziapi.common.utils.R;
import top.wshape1.shiziapi.project.domain.vo.SaveContentVo;
import top.wshape1.shiziapi.project.domain.vo.TwoIdVo;
import top.wshape1.shiziapi.project.service.MindmapService;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2025-01-07
 */

@RestController
@RequestMapping("/mindmap")
@RequiredArgsConstructor
public class MindMapController {

    private final MindmapService mindmapService;

    /**
     * 获取脑图内容
     *
     * @param contentVo
     * @return
     */
    @PostMapping("/content")
    public R<String> getContent(@RequestBody @Validated TwoIdVo contentVo) {

        String content = mindmapService.getContent(contentVo.getProjectId(), contentVo.getId());

        return R.ok().putData(content);
    }

    /**
     * 保存脑图内容
     *
     * @param contentVo
     * @return
     */
    @PostMapping("/content/save")
    public R<Void> saveContent(@RequestBody @Validated SaveContentVo contentVo) {

        mindmapService.SaveContent(contentVo);

        return R.ok();
    }


}
